package com.autumn.annotations.leetcode.leet;

import java.util.*;

/**
 * ClassName: SanShuZhiHe
 * Description:
 * Author: Shen_Yue
 * Date: 2023/5/18 2:31
 * History:
 * <author>          <time>          <version>          <desc>
 * Shen_Yue    2023/5/18 2:31   @Version 1.0        描述
 */
public class SanShuZhiHe {


    public List<List<Integer>> threeSum(int[] nums) {

        List<List<Integer>> result = new ArrayList<>();

        if (nums == null || nums.length <= 2) {
            List<Integer> list = new ArrayList<>();
            result.add(list);
            return result;
        }

        if (nums.length == 3) {
            if ((nums[0] + nums[1] + nums[2]) == 0) {
                List<Integer> list = new ArrayList<>();
                list.add(nums[0]);
                list.add(nums[1]);
                list.add(nums[2]);
                result.add(list);
                return result;
            }

            List<Integer> list = new ArrayList<>();
            result.add(list);
            return result;
        }

        for (int i = 0; i < nums.length - 2; i++) {
            for (int j = i + 1; j < nums.length - 1; j++) {
                for (int k = j + 1; k < nums.length; k++) {
                    if ((nums[i] + nums[j] + nums[k]) == 0) {

                        boolean isRepeat = false;
                        for (List<Integer> integers : result) {
                            Set<Integer> set = new HashSet<>();

                        }

                        List<Integer> list = new ArrayList<>();
                        list.add(nums[i]);
                        list.add(nums[j]);
                        list.add(nums[k]);
                        result.add(list);
                    }
                }
            }
        }

        if (result.size() == 0) {
            List<Integer> list = new ArrayList<>();
            result.add(list);
        }

        return result;
    }
}
